package org.example.service;

import lombok.RequiredArgsConstructor;
import org.example.model.entity.User;
import org.example.security.JwtManager;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class UserService {

    private final JwtManager jwtManager;

    public User login(User param) {
//        User user = userMapper.selectOne(lambdaQuery(User.class).eq(User::getUsername, param.getUsername()));
//        if (user == null || !passwordEncoder.matches(param.getPassword(), user.getPassword())) {
//            throw new RuntimeException("账号密码错误");
//        }
//        user.setToken(jwtManager.generate(user));
//        return user;
        User user = new User().setId(1).setUsername("admin");
        return user.setToken(jwtManager.generate(user));
    }
}
